package com.gotloop.controllers;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.gotloop.dto.UserDTO;
import com.gotloop.services.UserProfileService;

/**
 * Web Controller for everything related to an User.
 * @author jibhaine
 *
 */
public class UserController {

	/**
	 * Logger for UserController.
	 */
	private static final Logger LOG = LoggerFactory.getLogger(UserController.class);
	
	/**
	 * User Service.
	 */
	@Autowired
	private static UserProfileService userProfileService;
	
	/**
	 * Show user Profile page.
	 * @param userName the user name
	 * @return the userProfile page.
	 */
	@RequestMapping(value = "/user/{userName}")
	public ModelAndView showUserProfile(String userName) {
		LOG.debug("showUserProfile : {}", userName);
		UserDTO user = userProfileService.findUserByName(userName);
		return new ModelAndView("userProfile").addObject(user);
		
	}
	
}
